package com.corffen.design.responsechain;

import java.util.ArrayList;
import java.util.List;

public class ViewGroup extends View {

    public List<View> mChildren = new ArrayList<>();

    public void addView(View view) {
        mChildren.add(view);
    }

    public boolean dispatchTouchEvent(MotionEvent event) {

        boolean intercepted = onIntercept(event);
        if (intercepted) {
            return true;
        }
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            View child = mChildren.get(i);
            intercepted = child.dispatchTouchEvent(event);
            if (intercepted) {
                break;
            }
        }

        return intercepted;
    }

    public boolean onIntercept(MotionEvent event) {
        return false;
    }
}
